package 算法.NiuKe.JZ;

import 算法.NiuKe.TreeNode;

import java.util.*;

/**
 * @author:谢君臣
 * @Date:2021/3/228:55
 * @version:1.0
 * @function:
 */
public class JZ24 {
    public static void main(String[] args) {
    }
    ArrayList<Integer> path = new ArrayList<>();
    ArrayList<ArrayList<Integer>> res = new ArrayList<>();
    public ArrayList<ArrayList<Integer>> FindPath(TreeNode root, int target) {
        check(root,target);
        return res;
    }
    public void check(TreeNode node,int sum){
        if (node==null) return ;
        path.add(node.val);
        sum -=node.val;
        if (sum==0&&node.left==null&&node.right==null) {
            res.add(new ArrayList<>(path));
        }
        check(node.left,sum);
        check(node.right,sum);
        path.remove(path.size()-1);
    }
}
